# Copyright (C) 2018 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

load("@rules_proto//proto:defs.bzl", "proto_library")
load("//:version.bzl", "agi_version")
load("//tools/build:rules.bzl", "java_grpc_library")

java_library(
    name = "main",
    srcs = glob(["com/google/gapid/**/*.java"]) + [":version"],
    visibility = ["//visibility:public"],
    deps = [
        ":protos",
        ":service_grpc",
        "//gapic/src/platform",
        "@com_google_protobuf//:protobuf_java",
        "@gapic_third_party//:grpc",
        "@gapic_third_party//:guava",
        "@gapic_third_party//:jface",
        "@gapic_third_party//:lwjgl",
        "@gapic_third_party//:okhttp",
        "@gapic_third_party//:swt",
    ],
)

agi_version(
    name = "version",
    out = "com/google/gapid/util/GapidVersion.java",
    template = "com/google/gapid/util/GapidVersion.java.in",
)

java_grpc_library(
    name = "service_grpc",
    srcs = ["//gapis/service:service_proto"],
    deps = [
        ":protos",
        "@com_google_protobuf//:protobuf_java",
        "@gapic_third_party//:grpc",
        "@gapic_third_party//:guava",
    ],
)

java_library(
    name = "protos",
    exports = [
        ":settings_java_proto",
        "//core/data/pod:pod_java_proto",
        "//core/image:image_java_proto",
        "//core/log/log_pb:log_pb_java_proto",
        "//core/os/device:device_java_proto",
        "//core/stream:stream_java_proto",
        "//gapidapk/pkginfo:pkginfo_java_proto",
        "//gapis/api:api_java_proto",
        "//gapis/memory:memory_java_proto",
        "//gapis/perfetto/service:perfetto_java_proto",
        "//gapis/service:service_java_proto",
        "//gapis/service/box:box_java_proto",
        "//gapis/service/memory_box:memory_box_java_proto",
        "//gapis/service/path:path_java_proto",
        "//gapis/service/types:types_java_proto",
        "//gapis/stringtable:stringtable_java_proto",
        "//gapis/vertex:vertex_java_proto",
        "//tools/build/third_party/perfetto:config_java_proto",
    ],
)

proto_library(
    name = "settings_proto",
    srcs = ["com/google/gapid/settings.proto"],
    deps = [
        "//core/os/device:device_proto",
        "@perfetto//:protos_perfetto_config_merged_config_protos",
    ],
)

java_proto_library(
    name = "settings_java_proto",
    deps = [":settings_proto"],
)
